﻿using MahApps.Metro.Controls;
using System.Windows;
using System.Windows.Input;
using Kang.DbDoc.ViewModels;
using ICSharpCode.AvalonEdit.Highlighting;

namespace Kang.DbDoc.Views
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        public MainWindow()
        {
            InitializeComponent();

            if (this.DataContext is MainWindowViewModel model)
            {
                if (model == null)
                {
                    return;
                }
                model.Editor = editor;
            }
            editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("SQL");
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(editor);
        }

        private void chk_all_Checked(object sender, RoutedEventArgs e)
        {
            //datagrid.SelectAll();
        }

        private void chk_all_Unchecked(object sender, RoutedEventArgs e)
        {
            //datagrid.UnselectAll();
        }

        private void Editor_OnKeyDown(object sender, KeyEventArgs e)
        {
        }

        private void Editor_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyStates == Keyboard.GetKeyStates(Key.Z) && e.KeyboardDevice.Modifiers == ModifierKeys.Control)
            {
                e.Handled = true;
            }
            if (e.KeyStates == Keyboard.GetKeyStates(Key.Y) && Keyboard.Modifiers == ModifierKeys.Control)
            {
                e.Handled = true;
            }
        }
    }
}
